home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / cdrtools-1.10 / lib / stdio / cvmod.c next >
Encoding:
C/C++ Source or Header  |  1998-09-05  |  1.7 KB  |  56 lines

  1. /* @(#)cvmod.c    2.4 98/09/05 Copyright 1986, 1995 J. Schilling */
  2. /*
  3.  *    Copyright (c) 1986, 1995 J. Schilling
  4.  */
  5. /*
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2, or (at your option)
  9.  * any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; see the file COPYING.  If not, write to
  18.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #include <stdio.h>
  22. #include "io.h"
  23.  
  24. #ifndef    O_BINARY
  25. #define    O_BINARY    0
  26. #endif
  27.  
  28. int _cvmod(mode, omode, flag)
  29.     const char    *mode;
  30.     int        *omode;
  31.     int        *flag;
  32. {
  33.     while (*mode){
  34.         switch (*mode) {
  35.         
  36.         case 'r':   *omode |= O_RDONLY;    *flag |= FI_READ;    break;
  37.         case 'w':   *omode |= O_WRONLY;    *flag |= FI_WRITE;    break;
  38.         case 'e':   *omode |= O_EXCL;                break;
  39.         case 'c':   *omode |= O_CREAT;    *flag |= FI_CREATE;    break;
  40.         case 't':   *omode |= O_TRUNC;    *flag |= FI_TRUNC;    break;
  41.         case 'a':   *omode |= O_APPEND;    *flag |= FI_APPEND;    break;
  42.         case 'u':            *flag |= FI_UNBUF;    break;
  43.             /* dummy on UNIX */
  44.         case 'b':   *omode |= O_BINARY; *flag |= FI_BINARY;    break;
  45.         default:    raisecond(_badmode, 0L);
  46.                 return 0;
  47.         }
  48.         mode++;
  49.     }
  50.     if (*flag & FI_READ && *flag & FI_WRITE) {
  51.         *omode &= ~(O_RDONLY|O_WRONLY);
  52.         *omode |= O_RDWR;
  53.     }
  54.     return 1;
  55. }
  56.